 import RestUtil from "@/utils/rest-util";
 import TreeUtils from "@/utils/tree-utils"; 
 import _ from "lodash";
 //用户api
 export default class UserDeptApi{
     //获取部门
     public static async getDept(params:any){
        const result:any=await RestUtil.get("/api/system/dept/treeData",params);
        const orgData=result.data.map(item=>{
            return {
                label:item.title,
                id:item.id,
                pId:item.pId
            };
        });
        const reqOrgData=_.cloneDeep(orgData);
        const topItem:any=orgData.filter(item=>item.pId==0);
        TreeUtils.getTreeData(orgData,topItem[0]);
        return {topItem,reqOrgData};
    }
    //获取用户信息
    public static async getUserList(params:any){
          const result:any=await RestUtil.post("/api/system/user/list",params);
          return result;
    }
    //获取字典信息
    public static async selectDictDataByType(dictType:any){
         const result:any=await RestUtil.get(`/api/system/dict/selectDictDataByType/${dictType}`,{});
         return result;
     }
    //获取用户配置信息
    public static async getUserConfig(){
         const result:any=[
                {"value":"",type:"input",displayName:"用户工号",key:"userNo"},
                {"value":"",type:"input",displayName:"用户名",key:"userName"},
                {"value":"",type:"input",displayName:"登录名称",key:"loginName"},
                {"value":"",type:"input",displayName:"手机号码",key:"phonenumber"},
                {"value":"",type:"select",displayName:"用户状态",key:"status",selectItems:[{label:"有效",value:"0"},{label:"无效",value:"1"}]},
                {"value":"",type:"button",displayName:"搜索"},
                {"value":"",type:"button",displayName:"重置"}
         ];
         return result;
    }
    //获取用户列配置
    public static async getUserCloumns(){
         const columns:any=[
             {
                prop:"userId",
                width:"100",
                label:"用户ID"
             },
             {
                prop:"loginName",
                width:"100",
                label:"登录名称"
             },
             {
                prop:"userName",
                width:"100",
                label:"用户姓名"
             },
             {
                prop:"userNo",
                width:"120",
                label:"工号"
             },
             {
                prop:"dept.deptName",
                width:"150",
                label:"部门"
             },
             {
                prop:"status",
                width:"100",
                label:"用户状态",
                type:'switch'
             },
             {
                 prop:"createTime",
                 width:"150",
                 label:"创建时间"
             }
         ];
         return columns;
    }
}
